<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="./js/jquery.js"></script>
<script type="text/javascript" src="./js/jquery.cookie.js"></script>
</head>
<body>
	<div align="center">
		用户名:<input type="text" id="username">
		密码:<input type="password" id="password">
		<button onclick="Myfun()">登录</button>
	</div>
	<script type="text/javascript">
		function Myfun(){
			
			var name = $("#username").val();
			var pwd = $("#password").val();
			
			var json = {
					"user_name":name,
					"user_password":pwd
			}
			
			var str = JSON.stringify(json);
			
			console.log(str);
			
			$.ajax({
				url:"loginServlet",
				type:"post",
				data:str,
				async:true,
				datatype:"json",
				success:function(result){
					console.log(result);
					var json_rs = JSON.parse(result);
					var code = json_rs.Code;
					if(code == 0){
						alert(json_rs.comment);
					}else{
						alert(json_rs.comment);
						
						//sessionStorage.setItem("user_id",$.cookie('user_id'))
						//debugger;
						
						window.location.replace("http://localhost:8080/DyTransaction/main.html");
					}
				},
				error:function(error){
					alert(error);
				}
			})
		}
	</script>
</body>
</html>